package com.zhk.ScriptManagement.controller;

import com.zhk.ScriptManagement.entity.Permission;
import com.zhk.ScriptManagement.service.PermissionService;
import com.zhk.ScriptManagement.util.CodeMsg;
import com.zhk.ScriptManagement.util.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @Author: zhouhongkun
 * @Description: 权限controller
 * @Date: 2021/4/5 0:36
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;


    /**
     * 更新权限信息
     * @param permission
     * @return
     */
    @PostMapping("updatePermission")
//    @RequiresPermissions({"1"})
    public Result updatePermission(@RequestBody Permission permission){
        if(!Optional.ofNullable(permission).isPresent()){
            return Result.error(CodeMsg.PARAMETER_ISNULL,"参数不能为空");
        }
        return permissionService.updatePermission(permission);
    }
}
